(function (win) {
    // let login_input = document.querySelector('.login_input');

    let account = document.querySelector('#account');
    let password = document.querySelector('#password');
    let submit_button = document.querySelector('#submit_button');
    // 登录逻辑
    submit_button.addEventListener('click', function (e) {
        e.preventDefault();
        let accountValue = account.value;
        let passwordValue = password.value; 
        ajax({
            method: 'POST',
            url: urlRoot + 'login',
            data: {
                username: accountValue,
                password: passwordValue,
            },//data为传入的json数据
            header: {//post/put/delete 修改为 application/json
                'Content-type': 'application/json'
            },
        }).then((json) => {
            let name = json.data.username;
            console.log('成功，用户id:' + name);
            // 暂时设定为直接跳转到页面
            win.location.href = 'manager.html';
        }, (error) => {
            //登录失败的逻辑
            alert(error);
            // 后续改为加元素到页面
        });
    })
})(window);